#include "processBar.h"
#include <unistd.h>

typedef void(*callback)(int);

//模拟一种下载或者安装
void downLoad(callback cb)
{
    int total = 1000;
    int cur = 0;
    while(cur<=total)
    {
        usleep(50000);
        int rate = (cur*100/total);
        cb(rate);
        cur += 10;
    }
    printf("\n");
}

int main()
{
    printf("downLoad 1:\n");
    downLoad(processbar);
    initbar();

    printf("downLoad 2:\n");
    downLoad(processbar);
    initbar();
    printf("downLoad 3:\n");
    downLoad(processbar);
    initbar();
    printf("downLoad 4:\n");
    downLoad(processbar);
    initbar();
    return 0;
}
